package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysParise;
import com.ruoyi.project.system.service.ISysPariseService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 平台瞬间点赞Controller
 * 
 * @author jjp
 * @date 2020-04-14
 */
@RestController
@Api(description = "平台精彩瞬间点赞")
@RequestMapping("/system/parise")
public class SysPariseController extends BaseController
{
    @Autowired
    private ISysPariseService sysPariseService;

    /**
     * 查询平台瞬间点赞列表
     */
    @PreAuthorize("@ss.hasPermi('system:parise:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysParise sysParise)
    {
        startPage();
        List<SysParise> list = sysPariseService.selectSysPariseList(sysParise);
        return getDataTable(list);
    }

    /**
     * 获取平台瞬间点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:parise:query')")
    @GetMapping(value = "/{pariseId}")
    public AjaxResult getInfo(@PathVariable("pariseId") Long pariseId)
    {
        return AjaxResult.success(sysPariseService.selectSysPariseById(pariseId));
    }

    /**
     * 新增平台瞬间点赞
     */
    @PreAuthorize("@ss.hasPermi('system:parise:add')")
    @Log(title = "平台瞬间点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysParise sysParise)
    {
        return toAjax(sysPariseService.insertSysParise(sysParise));
    }

    /**
     * 修改平台瞬间点赞
     */
    @PreAuthorize("@ss.hasPermi('system:parise:edit')")
    @Log(title = "平台瞬间点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysParise sysParise)
    {
        return toAjax(sysPariseService.updateSysParise(sysParise));
    }

    /**
     * 删除平台瞬间点赞
     */
    @PreAuthorize("@ss.hasPermi('system:parise:remove')")
    @Log(title = "平台瞬间点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pariseIds}")
    public AjaxResult remove(@PathVariable Long[] pariseIds)
    {
        return toAjax(sysPariseService.deleteSysPariseByIds(pariseIds));
    }


    /**
     * 获取平台瞬间点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:parise:query')")
    @GetMapping(value = "/getMomentIdInfo/{momentId}")
    public TableDataInfo getMomentIdInfo(@PathVariable("momentId") Long momentId)
    {
        startPage();
        List<SysParise> sysParises = sysPariseService.selectSysPariseMomentId(momentId);
        return getDataTable(sysParises);
    }
}
